package Capa_Presentacion;


import java.util.ArrayList;
import java.util.List;


import Capa_Datos.CD_Software;
import Capa_Negocio.CN_ImplSoftServicio;

public class CP_TablaSw {

	
	
	private CN_ImplSoftServicio cn_impl;
	private List<CD_Software> listaSoftware;
	private CD_Software nuevo;
	private CD_Software selectedSoftware;
	public CD_Software getNuevo() {
		return nuevo;
	}


	public void setNuevo(CD_Software nuevo) {
		this.nuevo = nuevo;
	}

	public CP_TablaSw() {
		selectedSoftware = new CD_Software();
		nuevo = new CD_Software();
		cn_impl= new CN_ImplSoftServicio();
		listaSoftware = new ArrayList<CD_Software>();
		listaSoftware= cn_impl.getListaSw();
		
	}


public CD_Software getSelectedSoftware() {
	return selectedSoftware;
}

public void setSelectedSoftware(CD_Software selectedSoftware) {
    this.selectedSoftware = selectedSoftware;
}

public List<CD_Software> getListaSoftware() {
    return listaSoftware;
}
public void eliminar(){
	cn_impl.eliminar_sw(selectedSoftware);
	
	listaSoftware = new ArrayList<CD_Software>();
	listaSoftware= cn_impl.getListaSw();
	
}

public String modificar(){
	nuevo= new CD_Software();
	
	nuevo.setIdSoftware(selectedSoftware.getIdSoftware());
	nuevo.setNombre(selectedSoftware.getNombre());
	nuevo.setVersion(selectedSoftware.getVersion());
	return "ModificarSw";
	
}
public String cancelarModificacion(){
	
	return "ConsultaSwGeneral";
	
}
public String guardarModificacion(){
	try{
		
	
	selectedSoftware= getSelectedSoftware();
	selectedSoftware.getNombre();
	nuevo.getNombre();
	cn_impl.modificarSoftware(nuevo);
	listaSoftware = new ArrayList<CD_Software>();
	listaSoftware= cn_impl.getListaSw();
	}catch(Exception e){
		System.out.print("**********************pasa:"+nuevo.getNombre());
		
	}
	return "ConsultaSwGeneral";
	
}


	
	
	
}
